@import "../../themes/ionic.globals";

// Content
// --------------------------------------------------

:host {
  /**
   * @prop --background: Background of the content
   *
   * @prop --color: Color of the content
   *
   * @prop --padding-top: Top padding of the content
   * @prop --padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the content
   * @prop --padding-bottom: Bottom padding of the content
   * @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content
   *
   * @prop --keyboard-offset: Keyboard offset of the content
   *
   * @prop --offset-top: Offset top of the content
   * @prop --offset-bottom: Offset bottom of the content
   */
  --background: #{$background-color};
  --color: #{$text-color};
  --padding-top: 0px;
  --padding-bottom: 0px;
  --padding-start: 0px;
  --padding-end: 0px;
  --keyboard-offset: 0px;
  --offset-top: 0px;
  --offset-bottom: 0px;
  --overflow: auto;

  display: block;
  position: relative;

  flex: 1;

  width: 100%;
  height: 100%;

  /* stylelint-disable */
  margin: 0 !important;

  padding: 0 !important;
  /* stylelint-enable */

  font-family: $font-family-base;

  contain: size style;
}

:host(.ion-color) .inner-scroll {
  background: current-color(base);
  color: current-color(contrast);
}

// TODO we should remove outer-content in favor of a color
:host(.outer-content) {
  --background: #{$background-color-step-50};
}

#background-content {
  @include position(calc(var(--offset-top) * -1), 0px,calc(var(--offset-bottom) * -1), 0px);

  position: absolute;

  background: var(--background);
}

.inner-scroll {
  @include position(calc(var(--offset-top) * -1), 0px,calc(var(--offset-bottom) * -1), 0px);
  @include padding(calc(var(--padding-top) + var(--offset-top)), var(--padding-end), calc(var(--padding-bottom) + var(--keyboard-offset) + var(--offset-bottom)), var(--padding-start));

  position: absolute;

  color: var(--color);

  box-sizing: border-box;

  overflow: hidden;
}

.scroll-y,
.scroll-x {
  -webkit-overflow-scrolling: touch;

  /**
   * This adds `.inner-scroll` as part of the
   * stacking context in WebKit. Without it,
   * children of ion-content are treated as
   * siblings rather than descendants. This
   * can result in the children being put
   * into their own layers, degrading
   * scrolling performance.
   *
   * An optimization called "layer backing
   * sharing" usually kicks in to prevent
   * this, but having translate3d defeats
   * this optimization.
   *
   * See: https://bugs.webkit.org/show_bug.cgi?id=216701
   */
  z-index: 0;

  will-change: scroll-position;
}

.scroll-y {
  touch-action: pan-y;
  overflow-y: var(--overflow);
  overscroll-behavior-y: contain;
}

.scroll-x {
  touch-action: pan-x;
  overflow-x: var(--overflow);
  overscroll-behavior-x: contain;
}

.scroll-x.scroll-y {
  touch-action: auto;
}

.overscroll::before,
.overscroll::after {
  position: absolute;

  width: 1px;
  height: 1px;

  content: "";
}

.overscroll::before {
  bottom: -1px;
}

.overscroll::after {
  top: -1px;
}

:host(.content-sizing) {
  contain: none;
}
:host(.content-sizing) .inner-scroll {
  position: relative;
}

.transition-effect {
  display: none;
  position: absolute;

  /* stylelint-disable property-blacklist */
  left: -100%;
  /* stylelint-enable property-blacklist */

  width: 100%;
  height: 100vh;

  opacity: 0;

  pointer-events: none;
}

.transition-cover {
  position: absolute;

  /* stylelint-disable property-blacklist */
  right: 0;
  /* stylelint-enable property-blacklist */

  width: 100%;
  height: 100%;

  background: black;

  opacity: 0.1;
}

.transition-shadow {
  display: block;
  position: absolute;

  /* stylelint-disable property-blacklist */
  right: 0;
  /* stylelint-enable property-blacklist */

  width: 10px;
  height: 100%;

  background-image: url();
  background-repeat: repeat-y;
  background-size: 10px 16px;
}


// Content: Fixed
// --------------------------------------------------

::slotted([slot="fixed"]) {
  position: absolute;
}
